//
// Created by Administrator on 2023/8/2.
//


#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Solution {
public:
    bool checkDistances(string s, vector<int> &distance) {
        for (int i = 0; i < s.size(); ++i) {
            if (distance[s[i] - 'a'] == -1)continue;
            // 目标位置
            int targetPos = i + distance[s[i] - 'a'] + 1;
            if (targetPos >= s.size())return false;
            if (s[targetPos] != s[i]) return false;
            // -1 做标记 说明已经操作过了
            distance[s[i] - 'a'] = -1;
        }
        return true;
    }
};

int main() {
    Solution sol;
    string s = "abaccb";
    vector<int> distance = {1, 3, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    cout << sol.checkDistances(s, distance) << endl;
    return 0;
}